package user

import (
	"gysa-share01/exception"
	"gysa-share01/models/db"
	user2 "gysa-share01/models/user"
)

type UserServiceInterface interface {
	Info(userId uint) (user2.User, error)
}

type UserService struct {
}

func (u UserService) Info(userId uint) (userModel user2.User, err error) {
	model, err := db.Instance()
	if err != nil {
		return
	}
	err = model.Where("id = ?", userId).First(&userModel).Error
	if (userModel == user2.User{}) {
		err = exception.NewGeneralException("用户不存在", exception.RESOURCE_DOES_NOT_EXIST)
	}
	return
}
